/** 表格 v1.0.0 **/
var cdMap = new Map();
// 用户 user_nickName
cdMap.set("senderId", "user_nickName");
cdMap.set("updateBy", "user_nickName");
cdMap.set("createBy", "user_nickName");
// kaOptionButtons
var kaOptionButtonMaps = new Map();
var kaOptionTopMenuButtonMaps = new Map();
var kacolorFeilMap = new Map();
var kacolorMap = new Map();
var kagrid = {
    deConfig: { //默认参数
        elem: "", //对应绑定元素ID
        width: "100%", //宽度
        height: "100%", //高度
        paginationPageSize: 10,
        fv: [], // 初始查询字段
        fsv: [], // 初始排序字段
        column: [], //字段
    },
    rc: function (config, str) {//判断返回值
        return config[str] == undefined || config[str] == null || config[str] == "" ? kagrid.deConfig[str] : config[str];
    },
    setFV: function (config, arrayList) { //设置查询
        if (config.fv != undefined && config.fv != null && config.fv != "" && config.fv.length > 0) {
            for (var i in config.fv) {
                arrayList.push(config.fv[i]);
            }
        }
        var oldArrayList = ka_grid_findValue.get(config.id);
        if (oldArrayList != undefined && oldArrayList != null && oldArrayList != "") {
            for (var i in oldArrayList) {
                var al = oldArrayList[i];
                if(al.myuuid != undefined && al.myuuid != null && al.myuuid != ""){
                    continue;
                }
                arrayList.push(al);
            }
        }
        var oldShortcutArrayList = ka_grid_findShortcutValue.get(config.id);
        if (oldShortcutArrayList != undefined && oldShortcutArrayList != null && oldShortcutArrayList != "") {
            for (var i in oldShortcutArrayList) {
                var al = oldShortcutArrayList[i];
                al.myuuid = ka.uuidStr();
                arrayList.push(al);
            }
        }
        var newArrayList = [];
        for (var i in arrayList) {
            var al = arrayList[i];
            al.nal = "10001";
            if (al.myuuid == undefined || al.myuuid == null || al.myuuid == "") {
                al.myuuid = al.myuuid;
            }
            //判断等式
            if (al.equation == undefined || al.equation == null || al.equation == "") {
                al.equation = "1"
            }
            //判断连接
            if (al.andOr == undefined || al.andOr == null || al.andOr == "") {
                al.andOr = "and"
            }
            //判断值
            if (al.value == undefined || al.value == null || al.value == "") {
                continue;
            }
            newArrayList.push(al);
        }
        ka_grid_findValue.set(config.id, newArrayList);
    },
    setFSV: function (config, al) {//设置排序字段
        //判断等式
        if (al.field == undefined || al.field == null || al.field == "") {
            // layer.msg('请设置需要排序！');
        } else {
            if (al.orderby == undefined || al.orderby == null || al.orderby == "") {
                al.orderby = "descending";
            }
            ka_grid_sortValue.set(config.id, al);
        }
    },
    getData: function (config, cb) { //获取数量  
        top.ka_grid_kagridBoolean = false;
        if (config.dataType == 1) { //1:URL
            var option = kaValue.getUrl(config.url);
            var sortValue = ka_grid_sortValue.get(config.id);
            if (sortValue != undefined && sortValue != null && sortValue != "") {
                if (option.url.indexOf("?") > 0) {
                    option.url = option.url + "&orderByColumn=" + sortValue.field + "&isAsc=" + sortValue.orderby;
                } else {
                    option.url = option.url + "?orderByColumn=" + sortValue.field + "&isAsc=" + sortValue.orderby;
                }
            }
            if (config.fv != undefined && config.fv != null && config.fv != "" && config.fv.length > 0) {
                kagrid.setFV(config, []);
            }
            var findValue = ka_grid_findValue.get(config.id);
            if (findValue != undefined && findValue != null && findValue != "") {
                if (option["data"] == undefined || option["data"] == null) {
                    option["data"] = {};
                }
                option.data["queryParams"] = findValue;
                for (var i in findValue) {
                    var field = findValue[i].field;
                    var value = findValue[i].value;
                    option.data[field] = value;
                }
            }
            var pageSize = ka_grid_pageSize.get(config.id);
            if (pageSize != undefined && pageSize != null && pageSize != "") {
                if (option.url.indexOf("?") > 0) {
                    option.url = option.url + "&pageNum=" + pageSize.curr + "&pageSize=" + pageSize.pageSize;
                } else {
                    option.url = option.url + "?pageNum=" + pageSize.curr + "&pageSize=" + pageSize.pageSize;
                }
            } else {
                if (config.pagination) {
                    if (option.url.indexOf("?") > 0) {
                        option.url = option.url + "&paginationx = 1";
                    } else {
                        option.url = option.url + "?paginationx = 1";
                    }
                } else {
                    if (option.url.indexOf("?") > 0) {
                        option.url = option.url + "&pageNum=" + kaLayuiLaypage.curr + "&pageSize=" + kaLayuiLaypage.limit;
                    } else {
                        option.url = option.url + "?pageNum=" + kaLayuiLaypage.curr + "&pageSize=" + kaLayuiLaypage.limit;
                    }
                }
            }
            option.success = function (re) {
                top.ka_grid_kagridBoolean = true;
                if (re.code == 200) {
                    if (re.total != undefined && re.total != null && re.total != "") {
                        kalog.outLogs(["URL 表格数据:", re]);
                    } else {
                        if (re.data != undefined && re.data != null && re.data.length > 0) {
                            re.total = re.data.length;
                        } else {
                            re["number"] = 0;
                            re["data"] = [];
                            re["rows"] = [];
                            re["pageNum"] = "";
                            re["pageSize"] = "";
                            re["total"] = "";
                        }
                    }
                    cb(re.data, config);
                    kagrid.loadingPagination(config, re);
                }
            }
            ka.ajax(option);
        } else if (config.dataType == 2) { //2:本地JSON
            var option = {
                "url": kaValue.faCtx() + "/static/json/" + config.url,
                "async": true,
            };
            option.success = function (re) {
                if (re.code == 200) {
                    if (re.total != undefined && re.total != null && re.total != "") {
                        kalog.outLogs(["本地JSON 表格数据:", re]);
                    } else {
                        if (re.data != undefined && re.data != null && re.data.length > 0) {
                            re.total = re.data.length;
                        } else {
                            re["number"] = 0;
                            re["data"] = [];
                            re["rows"] = [];
                            re["pageNum"] = "";
                            re["pageSize"] = "";
                            re["total"] = "";
                        }
                    }
                    cb(re.data, config);
                    kagrid.loadingPagination(config, re);
                }
            }
            ka.ajax(option);
        } else if (config.dataType == 3) { //3:外站URL
            var option = {
                "url": config.url,
                "async": true,
            };
            option.success = function (re) {
                if (re.code == 200) {
                    if (re.total != undefined && re.total != null && re.total != "") {
                        re.total = re.data.length;
                        kagrid.loadingPagination(config, re);
                    } else {
                        if (re.data != undefined && re.data != null && re.data.length > 0) {
                            kalog.outLogs(["外站URL 表格数据:", re]);
                        } else {
                            re["total"] = 0;
                            re["data"] = [];
                            re["rows"] = [];
                            re["pageNum"] = "";
                            re["pageSize"] = "";
                            re["total"] = "";
                        }
                    }
                    cb(re.data, config);
                    kagrid.loadingPagination(config, re);
                }
            }
            ka.ajax(option);
        } else if (config.dataType == 4) { //4:自定义JSON
            var re = {
                "data": config.url
            }
            kalog.outLogs(["自定义JSON 表格数据:", re]);
            cb(re.data, config);
            kagrid.loadingPagination(config, re);
        }
    },
    getHtml: function (config) { // html
        var id = kagrid.rc(config, "id");
        var html = `<div id="AgKaGrid_` + id + `" style="width: ` + kagrid.rc(config, "width") + `;height: ` + kagrid.rc(config, "height") + `;"  class="ag-theme-balham"></div>`;
        config.id = id;
        return html;
    },
    getColumnDefs: function (config, kaposition) {
        var gct = config.gridcolumnType;//字段类型【1:URL,2:本地JSON,3:外站URL,4:自定义JSON】
        var columnDefs = [];
        if (gct == 0) {
            if (config.column != undefined && config.column != null && config.column != "") {
                if (Array.isArray(config.column) && config.column.length > 0) {
                    columnDefs = config.column;
                } else {
                    var option = kaValue.getUrl("getColumnByGrid");
                    option.url = option.url + "/" + config.column;
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) {
                            var cds = re.data;
                            for (var j in cds) {
                                var boolean = false;
                                var showPosition = cds[j].showPosition;
                                if (showPosition != undefined && showPosition != null && showPosition != "") {
                                    var showPositionArray = showPosition.split(",");
                                    for (var i in showPositionArray) {
                                        if (showPositionArray[i] == "1000" || showPositionArray[i] == kaposition) {
                                            boolean = true;
                                            break;
                                        }
                                    }
                                }
                                if (boolean) {
                                    columnDefs.push(cds[j]);
                                }
                            }
                        }
                    }
                    ka.ajax(option);
                }
            } else { // 加载字段后台字段
                columnDefs = [];
            }
        } else if (gct == 1) { //1:URL
            if (config.column != undefined && config.column != null && config.column != "") {
                if (Array.isArray(config.column) && config.column.length > 0) {
                    columnDefs = config.column;
                } else {
                    var option = kaValue.getUrl(config.column);
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) {
                            var cds = re.data;
                            for (var j in cds) {
                                var boolean = false;
                                var showPosition = cds[j].showPosition;
                                if (showPosition != undefined && showPosition != null && showPosition != "") {
                                    var showPositionArray = showPosition.split(",");
                                    for (var i in showPositionArray) {
                                        if (showPositionArray[i] == "1000" || showPositionArray[i] == kaposition) {
                                            boolean = true;
                                            break;
                                        }
                                    }
                                }
                                if (boolean) {
                                    columnDefs.push(cds[j]);
                                }
                            }
                        }
                    }
                    ka.ajax(option);
                }
            } else { // 加载字段后台字段
                columnDefs = [];
            }
        } else if (gct == 2) { //2:本地JSON
            if (Array.isArray(config.column) && config.column.length > 0) {
                columnDefs = config.column;
            } else {
                if (config.column != undefined && config.column != null && config.column != "") {
                    var option = {
                        "url": kaValue.faCtx() + "/static/json/" + config.column,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            columnDefs = re.data;
                        }
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    columnDefs = [];
                }
            }
        } else if (gct == 3) { //3:外站URL
            if (Array.isArray(config.column) && config.column.length > 0) {
                columnDefs = config.column;
            } else {
                if (config.column != undefined && config.column != null && config.column != "") {
                    var option = {
                        "url": config.column,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            var cds = re.data;
                            for (var j in cds) {
                                var boolean = false;
                                var showPosition = cds[j].showPosition;
                                if (showPosition != undefined && showPosition != null && showPosition != "") {
                                    var showPositionArray = showPosition.split(",");
                                    for (var i in showPositionArray) {
                                        if (showPositionArray[i] == "1000" || showPositionArray[i] == kaposition) {
                                            boolean = true;
                                            break;
                                        }
                                    }
                                }
                                if (boolean) {
                                    columnDefs.push(cds[j]);
                                }
                            }
                        }
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    columnDefs = [];
                }
            }
        } else if (gct == 4) { //4:自定义JSON
            if (config.column != undefined && config.column != null && config.column != "" && config.column.length > 0) {
                columnDefs = config.column;
            } else { // 加载字段后台字段
                columnDefs = [];
            }
        } else if (gct == 4) { //5:其他 JSON
            if (config.column != undefined && config.column != null && config.column != "") {
                if (Array.isArray(config.column) && config.column.length > 0) {
                    columnDefs = config.column;
                } else {
                    var option = kaValue.getUrl("getOtherColumn");
                    option.url = option.url + "/" + config.column;
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) {
                            var cds = re.data;
                            for (var j in cds) {
                                var boolean = false;
                                var showPosition = cds[j].showPosition;
                                if (showPosition != undefined && showPosition != null && showPosition != "") {
                                    var showPositionArray = showPosition.split(",");
                                    for (var i in showPositionArray) {
                                        if (showPositionArray[i] == "1000" || showPositionArray[i] == kaposition) {
                                            boolean = true;
                                            break;
                                        }
                                    }
                                }
                                if (boolean) {
                                    columnDefs.push(cds[j]);
                                }
                            }
                        }
                    }
                    ka.ajax(option);
                }
            } else { // 加载字段后台字段
                columnDefs = [];
            }
        }
        return columnDefs;
    },
    getColumn: function (config, kaposition) { //字段
        var gin = config.gridIsnumber; //显示序号【0:不显示,1:显示】
        var gic = config.gridIscheckbox; //显示序号【0:不显示,1:显示】
        var button = config.button;
        var kaposition = config.kaposition;//默认（1003）显示位置【1001:编辑,1002:新增,1003:列表,1004:列表查询,1005:选择带回列表,1006:选择带回列表查询,1007:上查列表,1008:上查列表查询,1009:下查列表,1010:下查列表查询】
        if (kaposition == undefined || kaposition == null || kaposition == "") {
            kaposition = "1003";
        }
        var columnDefs = kagrid.getColumnDefs(config, kaposition);
        //组装 字段列表
        var cols = [];
        //判断用户自定义 -- 序号
        if (gin == 1) {
            cols.push({
                headerName: "", pinned: "left", width: 50, maxWidth: 50,
                headerClass: 'ag-header-center',
                valueGetter: function (params) {
                    return params.node ? (params.node.rowIndex + 1) : null
                },
                cellStyle: { "text-align": "center", "background-color": "#fafafa", "border-right": "1px solid #e7e7e7", "padding-left": "0px", "padding-right": "0px" },
                suppressSizeToFit: true,
                suppressMenu: true,
                noci: 0,
                kaconfig: config
            });
        }
        //判断用户自定义 -- 复选框
        if (gic == 1) {
            cols.push({
                headerName: '',
                pinned: "left",
                checkboxSelection: true,
                headerClass: 'ag-header-center',
                headerCheckboxSelection: true,
                width: 42,
                maxWidth: 42,
                cellStyle: { "text-align": "center" },
                enableFilter: false,
                suppressSizeToFit: true,
                suppressMenu: true,
                noci: 0,
                kaconfig: config
            });
        }
        //加载按钮
        kagrid.rowButton(button, cols, config);
        //判断是否
        var myColumn = config.myColumn;
        //加载其他字段
        for (var i in columnDefs) {
            var cs = columnDefs[i];
            if (myColumn != undefined && myColumn != null && myColumn.length > 0) {
                var booleans = true;
                for (var k in myColumn) {
                    if (myColumn[k] == cs.field) {
                        booleans = false;
                        break;
                    }
                }
                if (booleans) {
                    continue;
                }
            }
            cs["kaconfig"] = config;
            var dt = cdMap.get(cs.field);
            if (dt != undefined && dt != null && dt != "") {
                if (cs["width"] == undefined || cs["width"] == null || cs["width"] == "") {
                    var kawidth = kagrid.convertWidth(cs.field);
                    cs["width"] = kawidth;
                    cs["minWidth"] = kawidth;
                }
                cs.cellRenderer = function (d) {
                    var value = d.value;
                    if (value != undefined && value != null) {
                        value = kagrid.convertData(d.value, d.colDef.field);
                        return `<a href="javascript:void(0);" onclick="alert('` + d.data.id + `');">` + value + `</a>`;
                    } else {
                        return value;
                    }
                }
            } else if (columnDefs[i].dataType == 2) {
                // cs["headerClass"] = 'ag-header-center';
                // cs["cellStyle"] = { "text-align": "center" };
                var headerName = columnDefs[i].headerName;
                var dicwidthInter = headerName.length * 23;
                if (headerName.length < 4) {
                    dicwidthInter = 100;
                }
                if (cs["width"] == undefined || cs["width"] == null || cs["width"] == "") {
                    cs["width"] = dicwidthInter;
                    cs["minWidth"] = dicwidthInter;
                    cs["maxWidth"] = dicwidthInter;
                }

                cs.cellRenderer = function (d) {
                    var value = d.value;
                    if (value != undefined && value != null) {
                        value = kagrid.convertData2((d.colDef.field == "delFlag" || d.colDef.field == "del_flag") ? "sys_del_flag" : d.colDef.code, d.value);
                        return `<a href="javascript:void(0);" onclick="alert('` + d.data.id + `');">` + value + `</a>`;
                    } else {
                        return value;
                    }
                }
            }
            var columnDefsCode = columnDefs[i].code;
            if(columnDefsCode != undefined && columnDefsCode != null && columnDefsCode != ""){
                var optionz = kaValue.getUrl("getColumnrender");
                optionz.async = false;
                optionz.url = optionz.url + "/" + columnDefsCode
                optionz.success = function (re) {
                    if (re.code == 200) {
                        if (re.data.length > 0) {
                            cs.columnrender = re.data[0].data
                        }
                    }
                }
                ka.ajax(optionz);
            }
            if (cs.columnrender != undefined && cs.columnrender != null && cs.columnrender != "") {
                cs.cellRenderer = function (d) {
                    var uuid = ka.uuidStr();
                    ka_grid_columnMap.set(uuid, d);
                    return ka.exec("var duuid = '" + uuid + "';var d = ka_grid_columnMap.get(duuid);ka_grid_columnMap.delete(duuid);" + d.colDef.columnrender);
                }
            }

            // 创建时间
            if (cs.field == "createTime" || cs.field == "updateTime") {
                cs["width"] = 150;
                cs["minWidth"] = 150;
                cs["maxWidth"] = 150;
            }
            // 创建时间
            if (cs.field == "code" || cs.field == "code") {
                cs["width"] = 150;
                cs["minWidth"] = 150;
            }
            cs["kaconfig"] = config
            cols.push(cs);
        }
        return cols;
    },
    getQueryColumn: function (config) { //字段
        var kaposition = config.kaposition;//默认（1003）显示位置【1001:编辑,1002:新增,1003:列表,1004:列表查询,1005:选择带回列表,1006:选择带回列表查询,1007:上查列表,1008:上查列表查询,1009:下查列表,1010:下查列表查询】
        kaposition = (config.kaposition == "1003" ? "1004" : config.kaposition == "1005" ? "1006" : config.kaposition == "1007" ? "1008" : config.kaposition == "1009" ? "1010" : "");
        var columnDefs = kagrid.getColumnDefs(config, kaposition);
        return columnDefs;
    },
    rowButton: function (button, cols, config) { //行菜单按钮
        if (button == undefined) {
            return false;
        }
        if (button.type == undefined) {
            return false;
        }
        kaOptionButtonMaps = new Map();
        if (button != undefined && button != null && button != "") {
            var buttonType = button.type;
            var buttonData = button.datajson;
            var opt = {
                headerName: '操作',
                pinned: "left",
                field: 'kaOptionButtons',
                headerClass: 'ag-header-center',
                suppressMenu: true,
                cellStyle: { "text-align": "center" },
                buttonType: buttonType, //【1:URL,2:本地JSON,3:外站URL,4:自定义JSON】
                button: buttonData,
                noci: 0,
                kaconfig: config
            };
            opt["kaSort"] = false;
            opt["suppressMenu"] = true;
            if (buttonType == 0) { //0:系统自带
                var option = kaValue.getUrl("getButtonQuery");
                option.url = option.url + "?gridId=" + config.grid;
                option.async = false;
                option.success = function (re) {
                    if (re.code == 200) {
                        var buttons = re.data;
                        for (var k in buttons) {
                            buttons[k].buttonIds = buttons[k].buttonIds;
                            buttons[k].dataJsonStr = buttons[k].data;
                            buttons[k].grid = config.grid;
                            buttons[k].config = config;
                            buttons[k].buttonTypes = buttons[k].type;;
                            buttons[k].uuidString = ka.uuidStr();
                            buttons[k].cb = function (d) {
                                var type = this.buttonTypes;
                                var config = this.config;
                                var uuidString = this.uuidString;
                                var geturl = this.geturl;
                                var submiturl = this.submiturl;
                                var submitway = this.submitway;
                                d.geturl = geturl;
                                d.submiturl = submiturl;
                                d.submitway = submitway;
                                top.ka_grid_rowsMap.set(uuidString + "String", d);
                                if (type == 1) {
                                    ka.exec("var buttonidsStrId = '" + uuidString + "String';var d = top.ka_grid_rowsMap.get(buttonidsStrId);" + this.dataJsonStr);
                                } else if (type == 2) {
                                    if (this.dataJsonStr != undefined && this.dataJsonStr != null && this.dataJsonStr != "") {
                                        //加载
                                        var index = layer.open({
                                            type: 2,
                                            title: this.title,
                                            area: ['95%', '95%'],
                                            content: 'addAndEditView.html?formDesignerId=' + this.dataJsonStr + "&buttonidsStrId=" + uuidString + "String",
                                            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                                            btn: ['提交', '取消'],
                                            btnAlign: 'r',
                                            yes: function (index, layero) {
                                                // 获取 iframe 的窗口对象
                                                var iframeWin = window[layero.find('iframe')[0]['name']];
                                                var formPreviewForm = iframeWin.addAndEditViewIndex.getData(); // 获得 iframe 中某个输入框元素
                                                if (formPreviewForm != null) {
                                                    if (submitway != undefined && submitway != null && submitway != "") {
                                                        if (submitway == "1") {
                                                            formPreviewForm.id = d.data.id;
                                                        }
                                                    }
                                                    var option = kaValue.getUrl(submiturl);
                                                    option.data = formPreviewForm;
                                                    option.success = function (re) {
                                                        if (re.code == 200) {
                                                            layer.close(index);
                                                            kagrid.getData(config, function (reData, config) {
                                                                var gridApi = kagrid.getGridApi(config.id);
                                                                gridApi.setRowData(reData);
                                                                kagrid.playUpSort(config);
                                                                kaMsg.success(re);
                                                            })
                                                        } else {
                                                            kaMsg.error({ "code": re.code, "msg": re.msg });
                                                        }
                                                    }
                                                    ka.ajax(option);
                                                }
                                            }
                                        });
                                    } else {
                                        var gridId = this.grid;
                                        var buttonIds = this.buttonIds;
                                        layer.open({
                                            type: 1, // page 层类型
                                            area: ['80%', '80%'],
                                            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                                            title: '未配置表单设计，请配置。',
                                            shadeClose: true, // 点击遮罩区域，关闭弹层
                                            maxmin: false, // 允许全屏最小化
                                            anim: 0, // 0-6 的动画形式，-1 不开启
                                            content: `
                                                <input type="hidden" id="updateFormdesignerMainSelectButtonId" value="`+ buttonIds + `" class="layui-input">
                                                <div style="padding: 5%;padding-bottom: 0px;padding-left: 20px;padding-right: 20px;"><div id="updateFormdesignerMainSelect" class="xm-select-demo"></div></div>
                                                <div style="width: 100%;text-align: center;margin-top: 15px;"><button id="updateFormdesignerMainSelectButton" type="button" class="layui-btn">确认</button></div>
                                            `,
                                            success: function (layero, index, that) {
                                                $("#updateFormdesignerMainSelectButton").click(function () {
                                                    var formDesignerXMSelect = top.ka_grid_formDesignerSelectMap.get("updateFormdesignerMainSelect");
                                                    var selectArr = formDesignerXMSelect.getValue();
                                                    var updateFormdesignerMainSelectButtonId = $("#updateFormdesignerMainSelectButtonId").val();
                                                    var option = kaValue.getUrl("SysGridButtonEdit");
                                                    option.async = false;
                                                    option.data = {
                                                        id: updateFormdesignerMainSelectButtonId,
                                                        data: selectArr[0].id
                                                    }
                                                    option.success = function (re) {
                                                        if (re.code == 200) {
                                                            window.location.reload();
                                                        }
                                                    }
                                                    option.error = function (re) {
                                                        return false;
                                                    }
                                                    ka.ajax(option);
                                                });
                                                var kaFormdesignerMainData = [];
                                                var option = kaValue.getUrl("formdesignerMainList");
                                                option.async = false;
                                                option.data = {
                                                    gridId: gridId
                                                }
                                                option.success = function (re) {
                                                    if (re.code == 200) {
                                                        kaFormdesignerMainData = re.data;
                                                    }
                                                }
                                                option.error = function (re) {
                                                    return false;
                                                }
                                                ka.ajax(option);
                                                ka.getXmSelect('updateFormdesignerMainSelect', {
                                                    radio: true,
                                                    clickClose: true,
                                                    paging: true,
                                                    pageSize: 10,
                                                    pageEmptyShow: false,
                                                    changeEvent: "",
                                                    model: {
                                                        icon: 'hidden',
                                                        label: {
                                                            type: 'text'
                                                        }
                                                    },
                                                    template({ item, sels, name, value }) {
                                                        return item.name + '<span style="position: absolute; right: 10px; color: #8799a3">' + value + '</span>'
                                                    },
                                                    data: kaFormdesignerMainData
                                                });
                                            }
                                        });
                                    }
                                } else if (type == 5){
                                    var kafvStr = "";
                                    if(submiturl!=undefined && submiturl!=null && submiturl!=""){
                                        var submiturlDataJson = JSON.parse(submiturl);
                                        for(var b in submiturlDataJson){
                                            submiturlDataJson[b].value = d.data[submiturlDataJson[b].value]
                                        }
                                        kafvStr = '&fvStr=' + encodeURIComponent(encodeURI(JSON.stringify(submiturlDataJson)));
                                    }
                                    var index = top.layer.open({
                                        type: 2, // page 层类型
                                        area: ['95%', '95%'],
                                        title: this.dataJsonStr,
                                        shadeClose: true, // 点击遮罩区域，关闭弹层
                                        maxmin: false, // 允许全屏最小化
                                        anim: 0, // 0-6 的动画形式，-1 不开启
                                        shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                                        content: 'grid.html?gridBodyId=' + geturl + '&fbAnd=1' + kafvStr,
                                      });
                                }
                            }
                        }
                        opt.button = buttons;
                    }
                }
                option.error = function (re) {
                    return false;
                }
                ka.ajax(option);
            } else if (buttonType == 1) { //1:URL
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = kaValue.getUrl(buttonData);
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 2) { //2:本地JSON
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = {
                        "url": kaValue.faCtx() + "/static/json/" + buttonData,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 3) { //3:外站URL
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = {
                        "url": buttonData,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 4) { //4:自定义JSON
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    opt.button = buttonData;
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            }
            var withs = 2 * 30;
            if (opt.button == undefined || opt.button == 0) {
                return false;
            }
            withs = withs + 10;
            if (config.rowButtonWidth != undefined && config.rowButtonWidth != null && config.rowButtonWidth != "") {
                withs = config.rowButtonWidth;
            }
            opt["width"] = withs;
            opt["minWidth"] = withs;
            opt["maxWidth"] = withs;
            opt["cellStyle"] = { "text-align": "center" };
            opt.cellRenderer = function (d) {
                var button = d.colDef.button;
                var buttonids = "kabutton" + ka.uuidStr();
                var newButtons = [];
                for (var i in button) {
                    var newButton = {}
                    $.extend(newButton, button[i]);
                    newButton.data = d;
                    newButtons.push(newButton);
                }
                kaOptionButtonMaps.set(buttonids, newButtons);
                if (button.length == 1) {
                    return `<a id="` + button[0].id + `" href="javascript:void(0);" onclick="kagrid.singleCbB('` + buttonids + `');">` + button[0].title + `</a>`;
                } else if (button.length > 1) {
                    var html = `
                        <a id="` + buttonids + `" href="javascript:void(0);" onclick="kagrid.dropdownOpen(this)">
                            <span>更多</span>
                            <i class="layui-icon layui-icon-down layui-font-12"></i>
                        </a>
                    `
                    return html;
                }
            }
            cols.push(opt);
        }
    },
    shortcutHtml: function (config) {
        var gridShortcutHtml = ``;
        gridShortcutHtml = gridShortcutHtml + `<a class="kaShortcutCss kaShortcutCssDis" onclick="kagrid.shortcutClick('0','` + config.id + `',this);">默认方案</a>`
        if(config.grid != undefined && config.grid != null && config.grid != ""){
            var option = kaValue.getUrl("getGridShortcut");
            option.url = option.url + "/" + config.grid;
            option.async = false;
            option.success = function (re) {
                if (re.code == 200) {
                    var shortcuts = re.data;
                    for (var k in shortcuts) {
                        gridShortcutHtml = gridShortcutHtml + `<a id="` + shortcuts[k].id + `" class="kaShortcutCss" onclick="kagrid.shortcutClick('` + shortcuts[k].id + `','` + config.id + `',this);">` + shortcuts[k].title + `</a>`
                    }
                }
            }
            option.error = function (re) {
                return false;
            }
            ka.ajax(option);
        }
        return gridShortcutHtml;
    },
    shortcutClick: function (shortcutsId, configid, that) {
        $("#AgKaGrid_" + configid + " .kaShortcutCss").removeClass("kaShortcutCssDis");
        $(that).addClass("kaShortcutCssDis");
        if(shortcutsId != "0"){
            var config = ka_grid_config_div.get(configid);
            var option = kaValue.getUrl("SysGridShortcutGetInfo");
            option.url = option.url + "/" + shortcutsId;
            option.async = false;
            option.success = function (re) {
                if (re.code == 200) {
                    var arrayList = [];
                    var objArray = JSON.parse(re.data.data)
                    for(var i in objArray){
                        var obj = objArray[i];
                        obj.myuuid = ka.uuidStr();
                        arrayList.push(obj);
                    }
                    ka_grid_findShortcutValue.set(config.id, arrayList);
                    kagrid.setFV(config, []);
                    kagrid.getData(config, function (reData, config) {
                        var gridApi = kagrid.getGridApi(config.id);
                        gridApi.setRowData(reData);
                        kagrid.playUpSort(config);
                    })
                }
            }
            option.error = function (re) {
                return false;
            }
            ka.ajax(option);
        } else {
            var config = ka_grid_config_div.get(configid);
            ka_grid_findShortcutValue.set(configid,[]);
            kagrid.setFV(config, []);
            kagrid.getData(config, function (reData, config) {
                var gridApi = kagrid.getGridApi(config.id);
                gridApi.setRowData(reData);
                kagrid.playUpSort(config);
            })
        }
    },
    topMenuHtml: function (config) { //顶部菜单按钮
        var topMenuButtons = config.topbutton;
        if (topMenuButtons != undefined && topMenuButtons != null && topMenuButtons != "") {
            var buttonData = topMenuButtons.datajson;
            var buttonType = topMenuButtons.type;
            if (buttonType != 0 && buttonType != 5) {
                if (buttonData == undefined || buttonData == null || buttonData == "") {
                    return ``;
                }
            }
            var opt = {};
            if (buttonType == 0) { //0:系统自带
                var option = kaValue.getUrl("getTopButtonQuery");
                option.url = option.url + "?gridId=" + config.grid;
                option.async = false;
                option.success = function (re) {
                    if (re.code == 200) {
                        var buttons = re.data;
                        for (var k in buttons) {
                            buttons[k].buttonIds = buttons[k].buttonIds;
                            buttons[k].dataJsonStr = buttons[k].data;
                            buttons[k].grid = config.grid;
                            buttons[k].config = config;
                            buttons[k].buttonTypes = buttons[k].type;
                            buttons[k].buttonGetnumbers = buttons[k].getnumber;
                            buttons[k].uuidString = ka.uuidStr();
                            buttons[k].cb = function () {
                                var d = {};
                                var buttonGetnumbers = this.buttonGetnumbers;
                                var buttonIds = this.buttonIds;
                                var buttonids = this.buttonids;
                                var config = this.config;
                                var gridApi = kagrid.getGridApi(config.id);
                                var selectedRowsData = gridApi.getSelectedRows();
                                var type = this.buttonTypes;
                                var geturl = this.geturl;
                                var submiturl = this.submiturl;
                                var submitway = this.submitway;
                                d.geturl = geturl;
                                d.submiturl = submiturl;
                                d.submitway = submitway;
                                if (buttonGetnumbers != undefined && buttonGetnumbers != null && buttonGetnumbers != "") {
                                    if(buttonGetnumbers > 0){
                                        if (selectedRowsData.length == buttonGetnumbers) {
                                            d.data = selectedRowsData;
                                        } else {
                                            kaMsg.error({ "code": 1000, "msg": "请选择" + buttonGetnumbers + "条数据！" });
                                            return false;
                                        }
                                    } else if(buttonGetnumbers == -1) {
                                        d.data = selectedRowsData;
                                    }
                                } else {
                                    d.data = {};
                                }
                                top.ka_grid_rowsMap.set(buttonids + "String", d);
                                if (type == 1) {
                                    ka.exec("var fvStr = '" + fvStr + "';var buttonidsStrId = '" + buttonids + "';var button = kaOptionTopMenuButtonMaps.get(buttonidsStrId);" + this.data);
                                } else if (type == 2) {
                                    if (this.dataJsonStr != undefined && this.dataJsonStr != null && this.dataJsonStr != "") {
                                        var fvStr = $.getUrlParam("fvStr");
                                        if(fvStr == undefined || fvStr == null || fvStr == ""){
                                            fvStr = "";
                                        } else {
                                            var fvStrObject = JSON.parse(decodeURI(decodeURIComponent(fvStr)));
                                            fvStr = "&fvStr=" + encodeURIComponent(encodeURI(JSON.stringify(fvStrObject)));
                                        }
                                        //加载
                                        var index = layer.open({
                                            type: 2,
                                            title: this.title,
                                            area: ['95%', '95%'],
                                            content: 'addAndEditView.html?formDesignerId=' + this.dataJsonStr + "&buttonidsStrId=" + buttonids + "String" + fvStr,
                                            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                                            btn: ['提交', '取消'],
                                            btnAlign: 'r',
                                            yes: function (index, layero) {
                                                // 获取 iframe 的窗口对象
                                                var iframeWin = window[layero.find('iframe')[0]['name']];
                                                var formPreviewForm = iframeWin.addAndEditViewIndex.getData(); // 获得 iframe 中某个输入框元素
                                                if (formPreviewForm != null) {
                                                    if (submitway != undefined && submitway != null && submitway != "") {
                                                        if (submitway == "1") {
                                                            formPreviewForm.id = d.data.id;
                                                        }
                                                    }
                                                    var option = kaValue.getUrl(submiturl);
                                                    option.data = formPreviewForm;
                                                    option.success = function (re) {
                                                        if (re.code == 200) {
                                                            layer.close(index);
                                                            kagrid.getData(config, function (reData, config) {
                                                                var gridApi = kagrid.getGridApi(config.id);
                                                                gridApi.setRowData(reData);
                                                                kagrid.playUpSort(config);
                                                                kaMsg.success(re);
                                                            })
                                                        } else {
                                                            kaMsg.error({ "code": re.code, "msg": re.msg });
                                                        }
                                                    }
                                                    ka.ajax(option);
                                                }
                                            }
                                        });
                                    } else {
                                        var gridId = this.grid;
                                        layer.open({
                                            type: 1, // page 层类型
                                            area: ['80%', '80%'],
                                            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                                            title: '未配置表单设计，请配置。',
                                            shadeClose: true, // 点击遮罩区域，关闭弹层
                                            maxmin: false, // 允许全屏最小化
                                            anim: 0, // 0-6 的动画形式，-1 不开启
                                            content: `
                                                <input type="hidden" id="updateFormdesignerMainSelectButtonId" value="`+ buttonIds + `" class="layui-input">
                                                <div style="padding: 5%;padding-bottom: 0px;padding-left: 20px;padding-right: 20px;"><div id="updateFormdesignerMainSelect" class="xm-select-demo"></div></div>
                                                <div style="width: 100%;text-align: center;margin-top: 15px;"><button id="updateFormdesignerMainSelectButton" type="button" class="layui-btn">确认</button></div>
                                            `,
                                            success: function (layero, index, that) {
                                                $("#updateFormdesignerMainSelectButton").click(function () {
                                                    var formDesignerXMSelect = top.ka_grid_formDesignerSelectMap.get("updateFormdesignerMainSelect");
                                                    var selectArr = formDesignerXMSelect.getValue();
                                                    var updateFormdesignerMainSelectButtonId = $("#updateFormdesignerMainSelectButtonId").val();
                                                    var option = kaValue.getUrl("SysGridTopbuttonEdit");
                                                    option.async = false;
                                                    option.data = {
                                                        id: updateFormdesignerMainSelectButtonId,
                                                        data: selectArr[0].id
                                                    }
                                                    option.success = function (re) {
                                                        if (re.code == 200) {
                                                            window.location.reload();
                                                        }
                                                    }
                                                    option.error = function (re) {
                                                        return false;
                                                    }
                                                    ka.ajax(option);
                                                });
                                                var kaFormdesignerMainData = [];
                                                var option = kaValue.getUrl("formdesignerMainList");
                                                option.async = false;
                                                option.data = {
                                                    gridId: gridId
                                                }
                                                option.success = function (re) {
                                                    if (re.code == 200) {
                                                        kaFormdesignerMainData = re.data;
                                                    }
                                                }
                                                option.error = function (re) {
                                                    return false;
                                                }
                                                ka.ajax(option);
                                                ka.getXmSelect('updateFormdesignerMainSelect', {
                                                    radio: true,
                                                    clickClose: true,
                                                    paging: true,
                                                    pageSize: 10,
                                                    pageEmptyShow: false,
                                                    model: {
                                                        icon: 'hidden',
                                                        label: {
                                                            type: 'text'
                                                        }
                                                    },
                                                    template({ item, sels, name, value }) {
                                                        return item.name + '<span style="position: absolute; right: 10px; color: #8799a3">' + value + '</span>'
                                                    },
                                                    data: kaFormdesignerMainData
                                                });
                                            }
                                        });
                                    }
                                } else if (type == 3) { // 删除
                                    var gridApi = kagrid.getGridApi(config.id);
                                    var selectedRowsData = gridApi.getSelectedRows();
                                    if (selectedRowsData.length <= 0) {
                                        kaMsg.error({ "code": 1000, "msg": "请选择至少一条数据！" });
                                        return false;
                                    }
                                    var dst = [];
                                    for (var i in selectedRowsData) {
                                        dst.push(selectedRowsData[i].id);
                                    }
                                    var dataStr = dst.join(",");
                                    kaMsg.warn({
                                        "code": 110, "msg": "确定删除吗？", cb: function () {
                                            var option = kaValue.getUrl(geturl);
                                            option.url = option.url + "/" + dataStr;
                                            option.success = function (re) {
                                                if (re.code == 200) {
                                                    kagrid.getData(config, function (reData, config) {
                                                        var gridApi = kagrid.getGridApi(config.id);
                                                        gridApi.setRowData(reData);
                                                        kagrid.playUpSort(config);
                                                        kaMsg.success(re);
                                                    })
                                                } else {
                                                    kaMsg.error({ "code": re.code, "msg": re.msg });
                                                }
                                            }
                                            ka.ajax(option);
                                        }
                                    });
                                } else if (type == 4) { // 清空
                                    var gridApi = kagrid.getGridApi(config.id);
                                    var selectedRowsData = gridApi.getSelectedRows();
                                    if (selectedRowsData.length <= 0) {
                                        kaMsg.error({ "code": 1000, "msg": "请选择至少一条数据！" });
                                        return false;
                                    }
                                    var dst = [];
                                    for (var i in selectedRowsData) {
                                        dst.push(selectedRowsData[i].id);
                                    }
                                    var dataStr = dst.join(",");
                                    kaMsg.warn({ "code": 110, "msg": "确定操作吗？", cb: function () {
                                            var option = kaValue.getUrl(geturl);
                                            option.url = option.url + "/" + dataStr;
                                            option.success = function (re) {
                                                if (re.code == 200) {
                                                    kagrid.getData(config, function (reData, config) {
                                                        var gridApi = kagrid.getGridApi(config.id);
                                                        gridApi.setRowData(reData);
                                                        kagrid.playUpSort(config);
                                                        kaMsg.success(re);
                                                    })
                                                } else {
                                                    kaMsg.error({ "code": re.code, "msg": re.msg });
                                                }
                                            }
                                            ka.ajax(option);
                                        }
                                    });
                                } else if (type == 5) { // 刷新缓存
                                    var gridApi = kagrid.getGridApi(config.id);
                                    kaMsg.warn({ "code": 110, "msg": "确定操作吗？", cb: function () {
                                            var option = kaValue.getUrl(geturl);
                                            option.success = function (re) {
                                                if (re.code == 200) {
                                                    kagrid.getData(config, function (reData, config) {
                                                        var gridApi = kagrid.getGridApi(config.id);
                                                        gridApi.setRowData(reData);
                                                        kagrid.playUpSort(config);
                                                        kaMsg.success(re);
                                                    })
                                                } else {
                                                    kaMsg.error({ "code": re.code, "msg": re.msg });
                                                }
                                            }
                                            ka.ajax(option);
                                        }
                                    });
                                } else if (type == 10) {
                                    var gridApi = kagrid.getGridApi(config.id);
                                    layer.prompt({title: this.title}, function(value, index, elem){
                                        if(value === '') return elem.focus();
                                        var selectedRowsData = gridApi.getSelectedRows();
                                        if (selectedRowsData.length <= 0) {
                                            kaMsg.error({ "code": 1000, "msg": "请选择至少一条数据！" });
                                            return false;
                                        }
                                        var dst = [];
                                        for (var i in selectedRowsData) {
                                            dst.push(selectedRowsData[i].id);
                                        }
                                        var dataStr = dst.join(",");
                                        var option = kaValue.getUrl(geturl);
                                            option.data = {
                                                ids: dataStr,
                                                bydgsl: value
                                            }
                                            option.success = function (re) {
                                                if (re.code == 200) {
                                                    kagrid.getData(config, function (reData, config) {
                                                        var gridApi = kagrid.getGridApi(config.id);
                                                        gridApi.setRowData(reData);
                                                        kagrid.playUpSort(config);
                                                        kaMsg.success(re);
                                                    })
                                                } else {
                                                    kaMsg.error({ "code": re.code, "msg": re.msg });
                                                }
                                            }
                                            ka.ajax(option);
                                        // 关闭 prompt
                                        layer.close(index);
                                    });
                                } else if (type == 11) { // 批量生成
                                    var gridApi = kagrid.getGridApi(config.id);
                                    var selectedRowsData = gridApi.getSelectedRows();
                                    if (selectedRowsData.length <= 0) {
                                        kaMsg.error({ "code": 1000, "msg": "请选择至少一条数据！" });
                                        return false;
                                    }
                                    var dst = [];
                                    for (var i in selectedRowsData) {
                                        dst.push(selectedRowsData[i].id);
                                    }
                                    var dataStr = dst.join(",");
                                    kaMsg.warn({
                                        "code": 110, "msg": "确定" + this.title + "吗？", cb: function () {
                                            var option = kaValue.getUrl(geturl);
                                            option.data = {
                                                ids: dataStr
                                            }
                                            option.success = function (re) {
                                                if (re.code == 200) {
                                                    kagrid.getData(config, function (reData, config) {
                                                        var gridApi = kagrid.getGridApi(config.id);
                                                        gridApi.setRowData(reData);
                                                        kagrid.playUpSort(config);
                                                        kaMsg.success(re);
                                                    })
                                                } else {
                                                    kaMsg.error({ "code": re.code, "msg": re.msg });
                                                }
                                            }
                                            ka.ajax(option);
                                        }
                                    });
                                }
                            }
                        }
                        opt.button = buttons;
                    }
                }
                option.error = function (re) {
                    return false;
                }
                ka.ajax(option);
            } else if (buttonType == 1) { //1:URL
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = kaValue.getUrl(buttonData);
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 2) { //2:本地JSON
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = {
                        "url": kaValue.faCtx() + "/static/json/" + buttonData,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 3) { //3:外站URL
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    var option = {
                        "url": buttonData,
                        "async": false,
                    };
                    option.success = function (re) {
                        if (re.code == 200) {
                            var buttons = re.data;
                            opt.button = buttons;
                        }
                    }
                    option.error = function (re) {
                        return false;
                    }
                    ka.ajax(option);
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            } else if (buttonType == 4) { //4:自定义JSON
                if (buttonData != undefined && buttonData != null && buttonData != "") {
                    opt.button = buttonData;
                } else { // 加载字段后台字段
                    opt.button = [];
                    return false;
                }
            }
            if (opt.button == undefined || opt.button == 0) {
                return ``;
            }
            var button = opt.button;
            kaOptionTopMenuButtonMaps = new Map();
            var html = `<div class="layui-btn-group">`;
            for (var i in button) {
                var buttonids = "kabutton" + ka.uuidStr();
                var ico = ``;
                if (button[i].ico != undefined && button[i].ico != null && button[i].ico != "") {
                    ico = `<i class="icon iconfont ` + button[i].ico + `" style="font-size: 12px;margin-right: 5px;"></i>`;
                }
                var background = button[i].color;
                var color = `color: var(--global-primary-color)!important;`;
                if (background == undefined || background == null || background == "") {
                    background = "";
                } else {
                    background = `
                    border-color: `+ button[i].color + ` !important;
                    `;
                    color = `color: ` + button[i].color + `!important;`;
                }
                html = html + `
                    <button id="` + buttonids + `" onclick="kagrid.topMenuClick('` + buttonids + `')" type="button" style="background: unset;cursor: pointer;
                    ` + color + background + `
                    font-size: 12px;height: 22px;line-height: 22px;margin-left: 5px;border-left: 1px solid;" class="layui-btn-primary layui-border-blue layui-btn-sm">`
                    + ico + button[i].title +
                    `</button>
                `;
                button[i].buttonids = buttonids;
                button[i].gridConfig = config;
                kaOptionTopMenuButtonMaps.set(buttonids, button[i]);
            }
            html = html + `</div>`;
            return html;
        } else {
            return ``;
        }
    },
    queryFeildLoade: function (config, qfds, filedsColumnTypes, filedsDataTypes, filedsDataValues) { //查询字段加载
        //初始化查询字段
        var boolean = false;
        var list = [];
        if (ka_grid_QueryType.get(config.id) != undefined && ka_grid_QueryType.get(config.id) != null) {
            list = ka_grid_QueryType.get(config.id);
        }
        if (qfds != undefined && qfds != null) {
            for (var i in qfds) {
                var blnum = 0;
                for (var j in list) {
                    if (list[j].qfd == qfds[i]) {
                        blnum = j;
                        break;
                    }
                    blnum = blnum + 1;
                }
                var returnData = kagrid.queryFeildHtml(config, blnum);
                returnData.qfd = qfds[i];
                returnData.columnTypes = filedsColumnTypes[i];
                returnData.dataTypes = filedsDataTypes[i];
                list.push(returnData);
                var queryType = "";
                if (filedsColumnTypes[i] == "varchar" || filedsColumnTypes[i] == "longtext") {
                    queryType = "109";
                    var fbAnd = config.fbAnd;
                    if (fbAnd) {
                        queryType = "101";
                    }
                } else if (filedsColumnTypes[i] == "int" || filedsColumnTypes[i] == "double") {
                    queryType = "101";
                } else if (filedsColumnTypes[i] == "datetime") {
                    queryType = "101";
                } else {
                    queryType = "109";
                    var fbAnd = config.fbAnd;
                    if (fbAnd) {
                        queryType = "101";
                    }
                }
                var fdv = "";
                if (filedsDataValues.length > 0) {
                    fdv = filedsDataValues[i];
                }
                var queryValue = {
                    queryFilter: qfds[i],
                    queryType: queryType,
                    dataType: returnData.dataTypes,
                    queryValue: fdv,
                    andOr: "and"
                };
                ka_grid_QueryValue.set(returnData.uuid, queryValue);
                boolean = true;
            }
        }
        if (boolean) {
            ka_grid_QueryType.set(config.id, list);
        }
    },
    queryFeildLoadeHtml: function (config) {//渲染到页面
        var kagid = "AgKaGrid_" + (config.id);
        $("#" + kagid + "_queryList").html("");
        var queryFeildList = ka_grid_QueryType.get(config.id);
        var booleanStr = false;
        var uuidstr = ka.uuidStr();
        for (var z in queryFeildList) {
            var queryFeildHtml = "";
            var returnData = queryFeildList[z];
            queryFeildHtml = returnData.html;
            if (queryFeildHtml != "") {
                queryListxx = `<div id="layuiForm` + uuidstr + `" lay-filter="layuiForm` + uuidstr + `" class="layui-form" style="width: 100%;"></div>`
                $("#" + kagid + "_queryList").html(queryListxx);
                $("#layuiForm" + uuidstr).append(queryFeildHtml);
                $("#layuiForm" + uuidstr).attr("configId",config.id);
                //绑定
                $("#layuiForm" + uuidstr).keydown(function(event){
                    if(event.keyCode == 13){
                        kagrid.queryData($(this).attr("configid"));
                        return false; 
                    }
                });
                layui.form.on('select(queryFilter_' + returnData.uuid + ')', function (data) {
                    var elem = data.elem; // 获得 select 原始 DOM 对象
                    var value = data.value; // 获得被选中的值z
                    var uuidStr = $(elem).attr("uuid");
                    var configid = $(elem).attr("configid");
                    var columnType = $("#query_filter_option_" + uuidStr + "_" + value).attr("columntype");
                    var dataType = $("#query_filter_option_" + uuidStr + "_" + value).attr("dataType");
                    var queryValue = ka_grid_QueryValue.get(uuidStr);
                    if (queryValue == undefined || queryValue == null) {
                        var queryType = "";
                        if (columnType == "varchar" || columnType == "longtext") {
                            queryType = "109";
                            var fbAnd = config.fbAnd;
                            if (fbAnd) {
                                queryType = "101";
                            }
                        } else if (columnType == "int" || columnType == "double") {
                            queryType = "101";
                        } else if (columnType == "datetime") {
                            queryType = "101";
                        } else {
                            queryType = "109";
                            var fbAnd = config.fbAnd;
                            if (fbAnd) {
                                queryType = "101";
                            }
                        }
                        queryValue = {
                            queryFilter: value,
                            queryType: queryType,
                            dataType: dataType,
                            queryValue: "",
                            andOr: "and"
                        };
                    } else {
                        var queryType = "";
                        if (columnType == "varchar" || columnType == "longtext") {
                            queryType = "109";
                            var fbAnd = config.fbAnd;
                            if (fbAnd) {
                                queryType = "101";
                            }
                        } else if (columnType == "int" || columnType == "double") {
                            queryType = "101";
                        } else if (columnType == "datetime") {
                            queryType = "101";
                        } else {
                            queryType = "109";
                            var fbAnd = config.fbAnd;
                            if (fbAnd) {
                                queryType = "101";
                            }
                        }
                        queryValue = {
                            queryFilter: value,
                            queryType: queryType,
                            queryValue: "",
                            andOr: "and"
                        };
                    }
                    var list = ka_grid_QueryType.get(configid);
                    for (var j in list) {
                        if (list[j].uuid == uuidStr) {
                            list[j].qfd = value;
                            break;
                        }
                    }
                    ka_grid_QueryType.set(config.id, list);
                    ka_grid_QueryValue.set(uuidStr, queryValue);
                    kagrid.queryFeildValue(configid);
                });
                layui.form.on('select(queryTypeSelect_' + returnData.uuid + ')', function (data) {
                    var elem = data.elem; // 获得 select 原始 DOM 对象
                    var value = data.value; // 获得被选中的值
                    var uuidStr = $(elem).attr("uuid");
                    var configid = $(elem).attr("configid");
                    var queryValue = ka_grid_QueryValue.get(uuidStr);
                    queryValue.queryType = value;
                    ka_grid_QueryValue.set(uuidStr, queryValue);
                    kagrid.queryFeildValue(configid);
                });
                booleanStr = true;
                if (queryFeildList.length == 1) {
                    $("#andOr_" + returnData.uuid).hide();
                }
                $("#addQuery_" + returnData.uuid).show();
                $("#queryButton_" + returnData.uuid + "_div").show();
                break;
            }
        }
        if (booleanStr) {
            layui.form.render();
            $("#" + kagid + "_queryList").show();
        }
    },
    queryFeildHtml: function (config, num) { //查询字段
        var uuid = ka.uuidStr();
        var returnData = {
            uuid: uuid,
            html: "",
            columnDefs: [],
            columnType: "",
            dataType: "",
            showPosition: "",
            config: config
        }
        var fb = config.fb;
        var fbAnd = config.fbAnd;
        var html = ``;
        if (fb) {
            var columnDefs = kagrid.getQueryColumn(config);
            var feildHtml = ``;
            for (var i in columnDefs) {
                var pyna = kaZhPinYinArray(columnDefs[i].headerName);
                var swStr = "";
                var swxxStr = "";
                for (var j in pyna) {
                    swStr = swStr + pyna[j][0].toUpperCase()
                    swxxStr = swxxStr + pyna[j][0].toLowerCase();
                }
                feildHtml = feildHtml + `<option id="query_filter_option_` + uuid + `_` + columnDefs[i].field + `" code="` + columnDefs[i].code + `" dataType="` + columnDefs[i].dataType + `" columnType="` + columnDefs[i].columnType + `" optionId="` + swxxStr + `" value="` + columnDefs[i].field + `">` + columnDefs[i].headerName + `</option>\r\n`;
                returnData.columnDefs.push(columnDefs[i]);
                returnData.showPosition = (columnDefs[i].showPosition != undefined && columnDefs[i].showPosition != null && columnDefs[i].showPosition != "") ? columnDefs[i].showPosition : "1000";
            }
            var mhtml = ``;
            if (num == 0) {
                mhtml = `margin-left: 5px;`;
            }
            var andOr_html = `
                <option value="and">并且</option>
                <option value="or">或者</option>
            `;
            if (fbAnd) {
                andOr_html = `
                    <option value="and">并且</option>
                `;
            }
            html = html + `
            <div id="layuiRow_querylist_` + uuid + `" class="layui-row layuiRow_querylist_` + config.id + `" style="margin-top: 5px;">
                <div class="layui-col-xs9" style="width: 515px;` + mhtml + `">
                    <div class="layui-row">
                        <div class="layui-col-xs2" style="padding-right: 5px;padding-left: 1px;width: 140px;">
                            <select id="queryFilter_` + uuid + `" configid="` + config.id + `" uuid="` + uuid + `" lay-search="" name="queryFilter" lay-filter="queryFilter_` + uuid + `">
                                ` + feildHtml + `
                            </select>
                        </div>
                        <div class="layui-col-xs2" id="queryType_` + uuid + `" style="padding-left: 5px;padding-right: 5px;width: 120px;">
                            <select id="queryTypeSelect_` + uuid + `" configid="` + config.id + `" uuid="` + uuid + `" name="queryType" lay-filter="queryTypeSelect_` + uuid + `">
                            </select>
                        </div>
                        <div class="layui-col-xs3" id="queryValue_` + uuid + `" style="padding-left: 5px;padding-right: 5px;width: 170px;">
                            <input onChange="kagrid.queryValueChange('` + uuid + `','` + config.id + `')" type="text" id="queryValueSelect_` + uuid + `" configid="` + config.id + `" uuid="` + uuid + `" name="queryValue" lay-filter="queryValueSelect_` + uuid + `" class="layui-input">
                        </div>
                        <div class="layui-col-xs1" id="andOr_` + uuid + `" style="padding-left: 5px;padding-right: 5px;width: 65px;">
                            <select id="andOrSelect_` + uuid + `" configid="` + config.id + `" uuid="` + uuid + `" name="andOr" lay-filter="andOrSelect_` + uuid + `">
                                ` + andOr_html + `
                            </select>
                        </div>
                        <div class="layui-col-xs1" id="delete_` + uuid + `" onclick="kagrid.deleteQueryValue(this)" configid="` + config.id + `" uuid="` + uuid + `" queryButtonId="addQuery_` + uuid + `" layuidropdownId="queryButtonIdaddQuery_` + uuid + `" style="width: 15px;height: 30px;line-height: 48px;text-align: center;display: none;">
                            <i class="icon iconfont icon-minus" style="font-size: 10px;padding: 1px;padding-top: 0px;padding-bottom: 0px;border: 1px solid #0066ff;color: #030303;background: #0066ff1c;"></i>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs2" id="addQuery_` + uuid + `" style="width: auto;display: none;">
                    <button id="addQuery_` + uuid + `" type="button" onclick="kagrid.openAddQueryFeildView('addQuery_` + uuid + `','` + config.id + `');" class="layui-btn-primary layui-border-blue layui-btn-xs" style="cursor: pointer;height: 30px;line-height: 30px;padding: 0 4px;border: 0px;">
                        <i class="icon iconfont icon-angle-double-down"></i>
                    </button>
                </div>
                <div id="queryButton_` + uuid + `_div" class="layui-col-xs2" style="padding-left: 5px;padding-right: 5px;display: none;">
                    <a id="queryButton_` + uuid + `" onclick="kagrid.queryData('` + config.id + `');" class="layui-btn layui-btn-sm">
                        <i class="icon iconfont icon-search" style="font-size: 11px;margin-right: 5px;"></i>查询
                    </a>
                </div>
            </div>
            `;
            returnData.html = html;
        }
        return returnData
    },
    queryData: function (configid) {
        var queryFeildList = ka_grid_QueryType.get(configid);
        var config = ka_grid_config_div.get(configid);
        var arrayList = [];
        for (var z in queryFeildList) {
            var returnData = queryFeildList[z];
            var uuid = returnData.uuid;
            var gridQueryValue = ka_grid_QueryValue.get(uuid);
            var json = {
                field: gridQueryValue.queryFilter,
                equation: gridQueryValue.queryType,
                andOr: gridQueryValue.andOr,
                value: gridQueryValue.queryValue
            }
            arrayList.push(json);
        }
        // nal
        var newArrayList = [];
        var oldArrayList = ka_grid_findValue.get(config.id);
        for (var j in oldArrayList) {
            if (oldArrayList[j].nal != "10001") {
                newArrayList.push(oldArrayList[j]);
            }
        }
        ka_grid_findValue.set(config.id, newArrayList);
        kagrid.setFV(config, arrayList);
        kagrid.getData(config, function (reData, config) {
            var gridApi = kagrid.getGridApi(config.id);
            gridApi.setRowData(reData);
            kagrid.playUpSort(config);
        })
    },
    queryValueChange: function (uuid, configid, that) {
        var value = $(that).val();
        var fromValue = ka_grid_QueryValue.get(uuid);
        fromValue.queryValue = value;
        ka_grid_QueryValue.set(uuid, fromValue);
    },
    deleteQueryValue: function (that) {
        var configid = $(that).attr("configid");
        var uuid = $(that).attr("uuid");
        var layuidropdownId = "";
        var uuidOne = "";
        var queryFeildList = ka_grid_QueryType.get(configid);
        var queryFeildNewList = [];
        for (var z in queryFeildList) {
            var returnData = queryFeildList[z];
            if (z == 0) {
                layuidropdownId = "queryButtonIdaddQuery_" + returnData.uuid
                uuidOne = "addQuery_" + returnData.uuid;
            }
            if (uuid != returnData.uuid) {
                queryFeildNewList.push(returnData);
            } else {
                ka_grid_QueryValue.delete(uuid);
            }
        }
        ka_grid_QueryType.set(configid, queryFeildNewList);
        layui.dropdown.close(layuidropdownId);
        kagrid.openAddQueryFeildView(uuidOne, configid);
        layui.dropdown.open(layuidropdownId);
    },
    addQueryFeild: function (that) {
        var id = $(that).attr("id");
        var layuidropdownId = $(that).attr("layuidropdownId");
        var queryButtonId = $(that).attr("queryButtonId");
        var configid = $(that).attr("configid");
        var config = ka_grid_config_div.get(configid);
        var value = $("#" + id).val();
        var uuid = $(that).attr("uuid");
        var columnDefs = kagrid.getQueryColumn(config);
        var fileds = [];
        var filedsColumnTypes = [];
        var filedsDataTypes = [];
        for (var k in columnDefs) {
            if (columnDefs[k].noci != 0 && columnDefs[k].field == value) {
                fileds.push(columnDefs[k].field);
                filedsColumnTypes.push(columnDefs[k].columnType);
                filedsDataTypes.push(columnDefs[k].dataType);
                boolean = true;
                break;
            }
        }
        kagrid.queryFeildLoade(config, fileds, filedsColumnTypes, filedsDataTypes, []); //
        kagrid.openAddQueryFeildView(queryButtonId, configid);
        layui.dropdown.close(layuidropdownId);
        layui.dropdown.open(layuidropdownId);
    },
    openAddQueryFeildView: function (queryButtonId, configid) {
        var content = ``;
        var queryFeildList = ka_grid_QueryType.get(configid);
        var uuidstrArry = [];
        for (var z in queryFeildList) {
            if (z >= 1) {
                var uuidstr = ka.uuidStr();
                var returnData = queryFeildList[z];
                content = content +
                    `<div id="layuiForm` + uuidstr + `" lay-filter="layuiForm` + uuidstr + `" class="layui-form" style="width: 100%;">` +
                    returnData.html +
                    `</div>`;
                uuidstrArry.push(uuidstr);
                $("#andOr_" + queryFeildList[0].uuid).show();
            }
        }
        var config = ka_grid_config_div.get(configid);
        var fbAnd = config.fbAnd;
        var list = [];
        if (ka_grid_QueryType.get(config.id) != undefined && ka_grid_QueryType.get(config.id) != null) {
            list = ka_grid_QueryType.get(config.id);
        }
        var columnDefs = kagrid.getQueryColumn(config);
        var feildHtml = ``;
        for (var i in columnDefs) {
            if (fbAnd) {
                var boolean = false;
                for (var j in list) {
                    if (list[j].qfd == columnDefs[i].field) {
                        boolean = true;
                        break;
                    }
                }
                if (boolean) {
                    continue;
                }
            }
            feildHtml = feildHtml + `<option value="` + columnDefs[i].field + `">` + columnDefs[i].headerName + `</option>\r\n`;
        }
        content = content + `
            <div style="width: 100%;line-height: 26px;height: 26px;">
                <select id="addQueryFeild_div_` + queryButtonId + `" layuidropdownId="queryButtonId` + queryButtonId + `" queryButtonId="` + queryButtonId + `" configid="` + configid + `" uuid="` + uuidstrArry.join(",") + `" name="addQueryFeildValue" onChange="kagrid.addQueryFeild(this)" style="border: 0px solid;margin-left: 0px;color: #06f;font-size: 12.4px;padding-left: 0px;">
                    <option value="">请选择查询字段</option>\r\n
                    ` + feildHtml + `
                </select>
            </div>`;
        layui.dropdown.render({
            id: "queryButtonId" + queryButtonId,
            elem: '#' + queryButtonId,
            content: content,
            align: 'right',
            className: 'add_query_feild_div_dropdown_tabs',
            ready: function () {
                var endStr = "";
                for (var z in queryFeildList) {
                    var returnData = queryFeildList[z];
                    if (z >= 1) {
                        $("#delete_" + returnData.uuid).show();
                        $("#queryButton_" + returnData.uuid + "_div").hide();
                        $("#addQuery_" + returnData.uuid).hide();
                        layui.form.on('select(queryFilter_' + returnData.uuid + ')', function (data) {
                            var elem = data.elem; // 获得 select 原始 DOM 对象
                            var value = data.value; // 获得被选中的值z
                            var uuidStr = $(elem).attr("uuid");
                            var configid = $(elem).attr("configid");
                            var columnType = $("#query_filter_option_" + uuidStr + "_" + value).attr("columntype");
                            var dataType = $("#query_filter_option_" + uuidStr + "_" + value).attr("dataType");
                            var queryValue = ka_grid_QueryValue.get(uuidStr);
                            if (queryValue == undefined || queryValue == null) {
                                var queryType = "";
                                if (columnType == "varchar" || columnType == "longtext") {
                                    queryType = "109";
                                    var fbAnd = config.fbAnd;
                                    if (fbAnd) {
                                        queryType = "101";
                                    }
                                } else if (columnType == "int" || columnType == "double") {
                                    queryType = "101";
                                } else if (columnType == "datetime") {
                                    queryType = "101";
                                } else {
                                    queryType = "109";
                                    var fbAnd = config.fbAnd;
                                    if (fbAnd) {
                                        queryType = "101";
                                    }
                                }
                                queryValue = {
                                    queryFilter: value,
                                    queryType: queryType,
                                    dataType: dataType,
                                    queryValue: "",
                                    andOr: "and"
                                };
                            } else {
                                var queryType = "";
                                if (columnType == "varchar" || columnType == "longtext") {
                                    queryType = "109";
                                    var fbAnd = config.fbAnd;
                                    if (fbAnd) {
                                        queryType = "101";
                                    }
                                } else if (columnType == "int" || columnType == "double") {
                                    queryType = "101";
                                } else if (columnType == "datetime") {
                                    queryType = "101";
                                } else {
                                    queryType = "109";
                                    var fbAnd = config.fbAnd;
                                    if (fbAnd) {
                                        queryType = "101";
                                    }
                                }
                                queryValue = {
                                    queryFilter: value,
                                    queryType: queryType,
                                    queryValue: "",
                                    andOr: "and"
                                };
                            }
                            var list = ka_grid_QueryType.get(configid);
                            for (var j in list) {
                                if (list[j].uuid == uuidStr) {
                                    list[j].qfd = value;
                                    break;
                                }
                            }
                            ka_grid_QueryType.set(configid, list);
                            ka_grid_QueryValue.set(uuidStr, queryValue);
                            kagrid.queryFeildValue(configid);
                        });
                        layui.form.on('select(queryTypeSelect_' + returnData.uuid + ')', function (data) {
                            var elem = data.elem; // 获得 select 原始 DOM 对象
                            var value = data.value; // 获得被选中的值
                            var uuidStr = $(elem).attr("uuid");
                            var configid = $(elem).attr("configid");
                            var queryValue = ka_grid_QueryValue.get(uuidStr);
                            queryValue.queryType = value;
                            ka_grid_QueryValue.set(uuidStr, queryValue);
                            kagrid.queryFeildValue(configid);
                        });
                        layui.form.render();
                        endStr = returnData.uuid;
                    }
                }
                $("#andOr_" + endStr).hide();
                kagrid.queryFeildValue(configid);
            }
        });
    },
    queryFeildValue: function (configid) {//渲染参数值
        var config = ka_grid_config_div.get(configid);
        var fbAnd = config.fbAnd;
        var queryFeildList = ka_grid_QueryType.get(configid);
        for (var z in queryFeildList) {
            var returnData = queryFeildList[z];
            // showPosition
            var fromValue = ka_grid_QueryValue.get(returnData.uuid);
            var layerFormId = $("#layuiRow_querylist_" + returnData.uuid).parent().attr("lay-filter");
            if (fromValue == undefined || fromValue == null) {
                fromValue = layui.form.val(layerFormId);
            }
            var columnType = $("#query_filter_option_" + returnData.uuid + "_" + fromValue.queryFilter).attr("columnType");
            var dataType = $("#query_filter_option_" + returnData.uuid + "_" + fromValue.queryFilter).attr("dataType");
            var code = $("#query_filter_option_" + returnData.uuid + "_" + fromValue.queryFilter).attr("code");
            if (columnType == "varchar" || columnType == "longtext") {
                //---------------------类型
                var queryTypeSelectHtml = `
                    <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_102" configid="` + configid + `" value="102">不等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_103" configid="` + configid + `" value="103">大于</option>
                    <option id="query_type_option_` + returnData.uuid + `_104" configid="` + configid + `" value="104">大于等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_105" configid="` + configid + `" value="105">小于</option>
                    <option id="query_type_option_` + returnData.uuid + `_106" configid="` + configid + `" value="106">小于等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_107" configid="` + configid + `" value="107">为空</option>
                    <option id="query_type_option_` + returnData.uuid + `_108" configid="` + configid + `" value="108">不为空</option>
                    <option id="query_type_option_` + returnData.uuid + `_109" configid="` + configid + `" value="109">包含</option>
                    <option id="query_type_option_` + returnData.uuid + `_110" configid="` + configid + `" value="110">不包含</option>
                    <option id="query_type_option_` + returnData.uuid + `_111" configid="` + configid + `" value="111">左包含</option>
                    <option id="query_type_option_` + returnData.uuid + `_112" configid="` + configid + `" value="112">右包含</option>
                `;
                if (fbAnd) {
                    queryTypeSelectHtml = `
                        <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    `;
                }
                $("#queryTypeSelect_" + returnData.uuid).html(queryTypeSelectHtml);

            } else if (columnType == "int" || columnType == "double") {
                var queryTypeSelectHtml = `
                    <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_102" configid="` + configid + `" value="102">不等于</option>
                `;
                if (fbAnd) {
                    queryTypeSelectHtml = `
                        <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    `;
                }
                $("#queryTypeSelect_" + returnData.uuid).html(queryTypeSelectHtml);
            } else if (columnType == "datetime") {
                var queryTypeSelectHtml = `
                    <option id="query_type_option_` + returnData.uuid + `_113" configid="` + configid + `" value="113">今天</option>
                    <option id="query_type_option_` + returnData.uuid + `_114" configid="` + configid + `" value="114">昨天</option>
                    <option id="query_type_option_` + returnData.uuid + `_115" configid="` + configid + `" value="115">明天</option>
                    <option id="query_type_option_` + returnData.uuid + `_116" configid="` + configid + `" value="116">上周</option>
                    <option id="query_type_option_` + returnData.uuid + `_117" configid="` + configid + `" value="117">本周</option>
                    <option id="query_type_option_` + returnData.uuid + `_118" configid="` + configid + `" value="118">下周</option>
                    <option id="query_type_option_` + returnData.uuid + `_119" configid="` + configid + `" value="119">上个月</option>
                    <option id="query_type_option_` + returnData.uuid + `_120" configid="` + configid + `" value="120">本月</option>
                    <option id="query_type_option_` + returnData.uuid + `_121" configid="` + configid + `" value="121">下个月</option>
                    <option id="query_type_option_` + returnData.uuid + `_122" configid="` + configid + `" value="122">月</option>
                    <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_104" configid="` + configid + `" value="104">大于等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_106" configid="` + configid + `" value="106">小于等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_102" configid="` + configid + `" value="102">不等于</option>
                    <option id="query_type_option_` + returnData.uuid + `_103" configid="` + configid + `" value="103">大于</option>
                    <option id="query_type_option_` + returnData.uuid + `_105" configid="` + configid + `" value="105">小于</option>
                    <option id="query_type_option_` + returnData.uuid + `_107" configid="` + configid + `" value="107">为空</option>
                    <option id="query_type_option_` + returnData.uuid + `_108" configid="` + configid + `" value="108">不为空</option>
                    <option id="query_type_option_` + returnData.uuid + `_123" configid="` + configid + `" value="123">今天之前(天)</option>
                    <option id="query_type_option_` + returnData.uuid + `_124" configid="` + configid + `" value="124">今天之后(天)</option>
                    <option id="query_type_option_` + returnData.uuid + `_125" configid="` + configid + `" value="125">今天之前第(天)</option>
                    <option id="query_type_option_` + returnData.uuid + `_126" configid="` + configid + `" value="126">今天之后第(天)</option>
                    <option id="query_type_option_` + returnData.uuid + `_127" configid="` + configid + `" value="127">今天之前N天以前</option>
                    <option id="query_type_option_` + returnData.uuid + `_128" configid="` + configid + `" value="128">今天之后N天以后</option>
                    <option id="query_type_option_` + returnData.uuid + `_129" configid="` + configid + `" value="129">单一日期</option>
                    <option id="query_type_option_` + returnData.uuid + `_130" configid="` + configid + `" value="130">小于等于今天</option>
                    <option id="query_type_option_` + returnData.uuid + `_131" configid="` + configid + `" value="131">大于等于今天</option>
                    <option id="query_type_option_` + returnData.uuid + `_132" configid="` + configid + `" value="132">小于今天</option>
                    <option id="query_type_option_` + returnData.uuid + `_133" configid="` + configid + `" value="133">大于今天</option>
                    <option id="query_type_option_` + returnData.uuid + `_134" configid="` + configid + `" value="134">今天之前N天以后</option>
                `;
                if (fbAnd) {
                    queryTypeSelectHtml = `
                        <option id="query_type_option_` + returnData.uuid + `_101" configid="` + configid + `" value="101">等于</option>
                    `;
                }
                $("#queryTypeSelect_" + returnData.uuid).html(queryTypeSelectHtml);
            }
            //---------------------值选择
            var queryValueHtml = ``;
            if (dataType == "1") {
                var disabledHtml = ``;
                if (fromValue.queryType == "107" || fromValue.queryType == "108") {
                    disabledHtml = `disabled`;
                }
                if (columnType == "int" || columnType == "double") {
                    queryValueHtml = `<input onChange="kagrid.queryValueChange('` + returnData.uuid + `','` + configid + `', this)"  type="number" ` + disabledHtml + ` id="queryValueSelect_` + returnData.uuid + `" configid="` + configid + `" uuid="` + returnData.uuid + `" name="queryValue" lay-filter="queryValueSelect_` + returnData.uuid + `" class="layui-input">`;
                } if (columnType == "datetime") {
                    queryValueHtml = `<input readonly type="text" ` + disabledHtml + ` id="queryValueSelect_` + returnData.uuid + `" configid="` + configid + `" uuid="` + returnData.uuid + `" name="queryValue" lay-filter="queryValueSelect_` + returnData.uuid + `" class="layui-input">`;
                } else {
                    queryValueHtml = `<input onChange="kagrid.queryValueChange('` + returnData.uuid + `','` + configid + `', this)"  type="text" ` + disabledHtml + ` id="queryValueSelect_` + returnData.uuid + `" configid="` + configid + `" uuid="` + returnData.uuid + `" name="queryValue" lay-filter="queryValueSelect_` + returnData.uuid + `" class="layui-input">`;
                }
            } else if (dataType == "2") {
                // queryValue_
                queryValueHtml = `
                     <select id="queryValueSelect_` + returnData.uuid + `" configid="` + configid + `" uuid="` + returnData.uuid + `" name="queryValue" lay-filter="queryValue_` + returnData.uuid + `">
                 `
                if (returnData.qfd == "delFlag" || returnData.qfd == "del_flag") {
                    code = "sys_del_flag";
                }
                var option = kaValue.getUrl("getDicDataByType");
                option.url = option.url + "/" + code;
                option.async = false;
                option.success = function (re) {
                    if (re.code == 200) {
                        var redata = re.data;
                        for (var j in redata) {
                            queryValueHtml = queryValueHtml +
                                `<option ` + (j == 0 ? "selected" : "") + ` id="query_value_option_` + returnData.uuid + `_` + redata[j].dictValue +
                                `" code="` + code + `" dataType="` + dataType + `" columnType="` + columnType + `" value="` + redata[j].dictValue + `">` +
                                redata[j].dictLabel + `</option>\r\n`;
                        }
                    }
                }
                ka.ajax(option);
                queryValueHtml = queryValueHtml + `</select>`
            } else {
                var disabledHtml = ``;
                if (fromValue.queryType == "107" || fromValue.queryType == "108") {
                    disabledHtml = `disabled`;
                }
                queryValueHtml = `<input onChange="kagrid.queryValueChange('` + returnData.uuid + `','` + configid + `')" type="text" id="queryValueSelect_` + returnData.uuid + `" ` + disabledHtml + ` configid="` + configid + `" uuid="` + returnData.uuid + `" name="queryValue" lay-filter="queryValueSelect_` + returnData.uuid + `" class="layui-input">`;
            }
            $("#queryValue_" + returnData.uuid).html(queryValueHtml);
            if (dataType == "1") {
                if (columnType == "datetime") {
                    if (fromValue.queryType == "113") { //今天
                        var result = layui.util.toDateString(new Date().getTime(), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "114") { // 昨天
                        var result = layui.util.toDateString((new Date().getTime() - 24 * 60 * 60 * 1000), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "115") { // 明天
                        var result = layui.util.toDateString((new Date().getTime() + 24 * 60 * 60 * 1000), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "116") { //上周
                        var result = layui.util.toDateString((new Date().getTime() - 7 * 24 * 60 * 60 * 1000), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "117") { // 本周
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "118") { // 下周
                        var result = layui.util.toDateString((new Date().getTime() + 7 * 24 * 60 * 60 * 1000), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "119") { // 上个月
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "120") { // 本月
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "121") { // 下个月
                        var result = layui.util.toDateString((new Date().getTime() - 24 * 60 * 60 * 1000), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "122") { // 月
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = "";
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        layui.laydate.render({
                            elem: '#queryValueSelect_' + returnData.uuid,
                            type: 'month',
                            done: function (value, date, endDate) {
                                var uuid = $("#" + this.id).attr("uuid");
                                var fromValue = ka_grid_QueryValue.get(uuid);
                                fromValue.queryValue = value;
                                ka_grid_QueryValue.set(uuid, fromValue);
                            }
                        });
                    } else if (fromValue.queryType == "123") { // 今天之前(天)
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "124") { // 今天之后(天)
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "125") { // 今天之前第(天)
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "126") { // 今天之后第(天)
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "127") { // 今天之前N天以前
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "128") { // 今天之后N天以后
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else if (fromValue.queryType == "129") { // 单一日期
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = "";
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        layui.laydate.render({
                            elem: '#queryValueSelect_' + returnData.uuid,
                            type: 'date',
                            done: function (value, date, endDate) {
                                var uuid = $("#" + this.id).attr("uuid");
                                var fromValue = ka_grid_QueryValue.get(uuid);
                                fromValue.queryValue = value;
                                ka_grid_QueryValue.set(uuid, fromValue);
                            }
                        });
                    } else if (fromValue.queryType == "130") { // 小于等于今天
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "131") { // 大于等于今天
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "132") { // 小于今天
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        $('#queryValueSelect_' + returnData.uuid).attr("disabled", "true");
                    } else if (fromValue.queryType == "133") { // 大于今天
                        var result = layui.util.toDateString((new Date().getTime()), 'yyyy-MM-dd HH:mm:ss');
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = result;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                    } else if (fromValue.queryType == "134") { // 今天之前N天以后
                        $('#queryValueSelect_' + returnData.uuid).attr("type", "number");
                        $('#queryValueSelect_' + returnData.uuid).removeAttr("readonly");
                    } else {
                        var fromValue = ka_grid_QueryValue.get(returnData.uuid);
                        fromValue.queryValue = fromValue.queryValue;
                        ka_grid_QueryValue.set(returnData.uuid, fromValue);
                        layui.laydate.render({
                            elem: '#queryValueSelect_' + returnData.uuid,
                            type: 'datetime',
                            done: function (value, date, endDate) {
                                var uuid = $("#" + this.id).attr("uuid");
                                var fromValue = ka_grid_QueryValue.get(uuid);
                                fromValue.queryValue = value;
                                ka_grid_QueryValue.set(uuid, fromValue);
                            }
                        });
                    }
                }
            } else if (dataType == "2") {
                layui.form.on('select(queryValue_' + returnData.uuid + ')', function (data) {
                    var elem = data.elem; // 获得 select 原始 DOM 对象
                    var value = data.value; // 获得被选中的值z
                    var uuid = $(elem).attr("uuid");
                    var fromValue = ka_grid_QueryValue.get(uuid);
                    fromValue.queryValue = value;
                    ka_grid_QueryValue.set(uuid, fromValue);
                });
            }
            //渲染
            layui.form.render();
            if (layerFormId != undefined && layerFormId != "") {
                layui.form.val(layerFormId, fromValue);
            }
        }
    },
    topMenuClick: function (buttonids) {
        var button = kaOptionTopMenuButtonMaps.get(buttonids);
        var gridConfig = button.gridConfig;
        button.cb(gridConfig);
    },
    loadingPagination: function (config, re) {
        if (!config.pagination) {
            var ka_grid_interval = setInterval(function () {
                if(top.ka_grid_kagridBoolean){
                    top.ka_grid_kagridBoolean = false;
                    var pageGridApi = ka_grid_pageGridApi.get('AgKaGrid_' + config.id);
                    var layouts = ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'];
                    var width = $("#AgKaGrid_" + config.id).width();
                    if (width <= 550) {
                        layouts = ['prev', 'page', 'next', 'limit', 'refresh'];
                    } else if (width > 550 && width <= 780) {
                        layouts = ['count', 'prev', 'page', 'next', 'limit', 'refresh'];
                    }
                    var laypagecurr = (re.pageNum != undefined && re.pageNum != null && re.pageNum != "" ? re.pageNum : "1");
                    var laypagelimit = (re.pageSize != undefined && re.pageSize != null && re.pageSize != "" ? re.pageSize : kaLayuiLaypage.limit);
                    layui.laypage.render({
                        elem: pageGridApi.id, // 元素 id
                        count: re.total, // 数据总数
                        limit: laypagelimit, // 每页显示的条数。
                        limits: kaLayuiLaypage.limits, // 每页条数的选择项
                        prev: `<i class="icon iconfont icon-caret-left"></i>`,//上一页
                        next: `<i class="icon iconfont icon-caret-right"></i>`,//下一页
                        curr: laypagecurr, // 初始化当前页码。
                        layout: layouts, // 功能布局
                        config: config,
                        jump: function (obj, first) {
                            var page = {
                                curr: obj.curr,
                                pageSize: obj.limit
                            }
                            ka_grid_pageSize.set(obj.config.id, page);
                            if (!first) {
                                kagrid.getData(config, function (reData, config) {
                                    var gridApi = kagrid.getGridApi(config.id);
                                    gridApi.setRowData(reData);
                                    kagrid.playUpSort(config);
                                })
                            }
                        }
                    });
                    clearInterval(ka_grid_interval);
                }
            }, 100);
        }
    },
    loading: function (config) {
        if(config.dataType == 4){
            kagrid.gridOptions(config);
        } else {
            var option = kaValue.getUrl("getGrid");
            option.url = option.url + "/" + config.id;
            option.success = function (re) {
                if (re.code == 200) {
                    $.extend(config, re.grids)
                    config.id = config.code;
                    kagrid.gridOptions(config,re);
                } else {
                    setTimeout(function () {
                        kaMsg.error(re);
                    }, 500);
                }
            }
            ka.ajax(option);
        }
    },
    gridOptions: function (config,re) {
        kagrid.getData(config, function (reData, config) {  //将列和数据赋给gridOptions 
            if (config.gridcolumnType == 0) {
                if (!(Array.isArray(config.column) && config.column.length > 0)) {
                    if(re != undefined){
                        config.column = re.grids.id;
                    }
                    
                }
                if(re != undefined){
                    config.grid = re.grids.id;
                }
            }
            var shortcutHtmlv = kagrid.shortcutHtml(config);
            var topMenuHtml = kagrid.topMenuHtml(config);
            var columnDefs = kagrid.getColumn(config);
            var gridOptions = {
                kagridid: 'AgKaGrid_' + config.id,
                columnDefs: columnDefs,
                rowData: reData,
                rowSelection: "multiple",
                onGridReady: function (e) { //表格创建完成后执行的事件
                    if (config.fsv != undefined && config.fsv != null && config.fsv != "") {
                        var al = config.fsv
                        kagrid.setFSV(config, al);
                        kagrid.playUpSort(config);
                    }
                    if (columnDefs.length > 12) {
                        const allColumnIds = [];
                        if (e.api.getAllColumns != undefined) {
                            e.api.getAllColumns().forEach((column) => {
                                allColumnIds.push(column.getId());
                            });
                        }
                        if (e.api.autoSizeColumns != undefined) {
                            e.api.autoSizeColumns(allColumnIds);
                        }
                    }
                    ka_grid_api.set(config.id, e.api)
                    if (topMenuHtml != "") {
                        $("#" + (gridOptions.kagridid) + "_topMenu").html(topMenuHtml);
                        $("#" + (gridOptions.kagridid) + "_topMenu").show();
                    }
                    if (shortcutHtmlv != "") {
                        $("#" + (gridOptions.kagridid) + "_shortcut").html(shortcutHtmlv);
                        $("#" + (gridOptions.kagridid) + "_shortcut_kjfs").show();
                    }
                    var fileds = [];
                    var filedsColumnTypes = [];
                    var filedsDataTypes = [];
                    for (var k in columnDefs) {
                        if (columnDefs[k].noci != 0) {
                            fileds.push(columnDefs[k].field);
                            filedsColumnTypes.push(columnDefs[k].columnType);
                            filedsDataTypes.push(columnDefs[k].dataType);
                            if (fileds.length == 1) {
                                break;
                            }
                        }
                    }
                    kagrid.queryFeildLoade(config, fileds, filedsColumnTypes, filedsDataTypes, []); //
                    kagrid.queryFeildLoadeHtml(config);
                    kagrid.queryFeildValue(config.id);
                },
                defaultColDef: {
                    editable: false,//单元表格是否可编辑
                    enableRowGroup: true,
                    enablePivot: true,
                    enableValue: true,
                    sortable: false, //开启排序
                    suppressMovable: false, //禁止拖动列的位置
                    resizable: true,//是否可以调整列大小，就是拖动改变列大小
                    filter: true  //开启刷选
                }
            };
            if (config.pagination) { //开启分页
                gridOptions.pagination = config.pagination;
                gridOptions.paginationPageSize = (config.paginationPageSize != undefined && config.paginationPageSize != null && config.paginationPageSize != "") ? config.paginationPageSize : deConfig.paginationPageSize; //pagesize
                gridOptions.paginationAutoPageSize = true; //根据网页高度自动分页（前端分页）
            } else { //关闭分页
                gridOptions.pagination = config.pagination;
            }
            //在dom加载完成后 初始化agGrid完成
            var eGridDiv = document.querySelector("#" + gridOptions.kagridid);
            new agGrid.Grid(eGridDiv, gridOptions);
        });
    },
    sortTable: function (field, headerName, apiuuid) { //排序table
        kalog.outLogs(["排序 ApiUuid:", apiuuid]);
        kalog.outLogs(["排序 field:", field]);
        kalog.outLogs(["排序 headerName:", headerName]);
        var gridApi = ka_grid_api.get(apiuuid).gridApi;
        var columnApi = ka_grid_api.get(apiuuid).columnApi;
        var config = ka_grid_config.get(apiuuid);
        kalog.outLogs(["排序 headerName:", config]);
        var sortAscDesc = "";
        var al = ka_grid_sortValue.get(config.id);
        if (al == undefined || al == null) {
            al = {
                field: field,
                orderby: "NULL"
            }
        }
        if (al.field == field) { sortAscDesc = al.orderby; } else { sortAscDesc = "NULL"; }
        if (sortAscDesc == "NULL") { sortAscDesc = "descending"; }
        else if (sortAscDesc == "descending") { sortAscDesc = "ascending"; }
        else if (sortAscDesc == "ascending") { sortAscDesc = "NULL"; }
        al = { "field": field, "orderby": sortAscDesc };
        if (al.orderby == "NULL") {
            ka_grid_sortValue.delete(config.id)
        } else {
            kagrid.setFSV(config, al);
        }
        gridApi.sizeColumnsToFit();//调整表格大小自适应 //表格创建完成后执行的事件
        const allColumnIds = [];
        columnApi.getAllColumns().forEach((column) => {
            allColumnIds.push(column.getId());
        });
        columnApi.autoSizeColumns(allColumnIds);
        kagrid.getData(config, function (reData, config) {
            var gridApi = kagrid.getGridApi(config.id);
            gridApi.setRowData(reData);
            kagrid.playUpSort(config);
        })
    },
    playUpSort: function (config) { // 渲染排序
        var al = ka_grid_sortValue.get(config.id);
        $("#AgKaGrid_" + config.id).find(".ka-agioci").remove();
        $("#AgKaGrid_" + config.id).find(".ka-agioc").each(function () {
            var sortField = $(this).attr("sortfield");
            if (al == undefined || al == null) {
                al = {
                    field: sortField,
                    orderby: "NULL"
                }
            }
            if (al.field == sortField) {
                if (al.orderby == "descending") {
                    $(this).parent().append(`<i class="ag-icon ag-icon-desc ka-agioci" kaSAD="descending"></i>`);
                } else if (al.orderby == "ascending") {
                    $(this).parent().append(`<i class="ag-icon ag-icon-asc ka-agioci" kaSAD="ascending"></i>`);
                }
            }
        });
    },
    convertData: function (value, field) { // 转换数据 dt:数据类型,value:值,typeMap:参数
        if (value != undefined && value != "") {
            var dt = cdMap.get(field);
            var returnValue = "";
            var dataJsonStr = sessionStorage.getItem(dt + "_" + value);
            if (dataJsonStr != undefined && dataJsonStr != null && dataJsonStr != "") {
                var dataJson = JSON.parse(dataJsonStr);
                var dts = dt.split("_");
                returnValue = dataJson[dts[1]];
            } else {
                var dts = dt.split("_");
                if (dts[0] == "user") {
                    var option = kaValue.getUrl("getUserById");
                    option.url = option.url + "/" + value;
                    option.async = false;
                    option.success = function (re) {
                        if (re.code == 200) { //user_nickName
                            var data = re.data;
                            sessionStorage.setItem(dt + "_" + value, JSON.stringify(re.data));
                            returnValue = data[dts[1]];
                        }
                    }
                    ka.ajax(option);
                }
            }
            return returnValue;
        } else {
            return "";
        }

    },
    convertData2: function (code, dictValue) {
        var returnValue = "";
        var dataJsonStr = sessionStorage.getItem(code);
        if (dataJsonStr != undefined && dataJsonStr != null && dataJsonStr != "") {
            var dataJson = JSON.parse(dataJsonStr);
            for (var i in dataJson) {
                if (dataJson[i].dictValue == dictValue) {
                    returnValue = dataJson[i].dictLabel;
                    break;
                }
            }
        } else {
            var option = kaValue.getUrl("getColumnDicValue");
            option.url = option.url + "/" + code + "/" + dictValue;
            option.async = false;
            option.success = function (re) {
                if (re.code == 200) { //user_nickName
                    var dataJson = re.data;
                    sessionStorage.setItem(code, JSON.stringify(dataJson));
                    for (var i in dataJson) {
                        if (dataJson[i].dictValue == dictValue) {
                            returnValue = dataJson[i].dictLabel;
                            break;
                        }
                    }
                }
            }
            ka.ajax(option);
        }
        return returnValue;
    },
    convertWidth: function (field) { // 转换宽度 找系统宽度
        var width = 0;
        var dt = cdMap.get(field);
        var dts = dt.split("_");
        if (dts[0] == "user") {
            width = 160;
        }
        return width;
    },
    dropdownOpen: function (that) {
        var id = $(that).attr("id");
        var value = kaOptionButtonMaps.get(id);
        // 渲染
        var options = {
            elem: '#' + id, // 绑定元素选择器
            data: value,
            click: function (obj, othis) {
                obj.cb(obj.data);
            }
        };
        layui.dropdown.render(options);
        layui.dropdown.reload(id, options)
        layui.dropdown.open(id)
    },
    singleCbB: function (uuid) {
        var value = kaOptionButtonMaps.get(uuid);
        value[0].cb(value[0].data);
    },
    getGridApi: function (configid) {
        var gridApi = ka_grid_api.get(configid).gridApi;
        if (gridApi == undefined) {
            gridApi = ka_grid_api.get(configid)
        }
        if (gridApi == undefined) {
            kaMsg.error({ "code": "500", "msg": "为获取到gridApi" });
            kalog.outLogs(["获取GetGridApi：", gridApi]);
        }
        return gridApi
    },
    AgKaSetFill: function () {
        
    },
    columnrender:{
        changeDOnchange: function(uuid){
            var id = $("#" + uuid + "_id").val();
            var column = $("#" + uuid + "_column").val();
            var url = $("#" + uuid + "_url").val();
            var value = $("#" + uuid + "_value").val();
            var option = kaValue.getUrl(url);
            option.data = {"id":id,"ids":id}
            option.data[column] = value;
            option.async = false;
            option.success = function (re) {
                if (re.code == 200) {
                    kaMsg.success(re);
                }
            }
            option.error = function (re) {
                return false;
            }
            ka.ajax(option);
        }
    }
}